/**
 * Created by shudong.msd(风骐) on 2016/4/17.
 */
'use strict';
app.controller('allMissionController',['$scope','dataFetcher','$state',function($scope,dataFetcherService,$state){

    $scope.proceeMission = dataFetcherService.proceeMission;
    $scope.allFinishMission = dataFetcherService.allFinishMission;

    $scope.loadMoreFinishData = function(){
        dataFetcherService.loadMoreData($scope,'all');
    };


    $scope.visitDetail  = function(mission){
        if(!mission.isSuccess)return;

        if(!mission.isRead){
            mission.isRead = true;
        }

        var searchData = {
            'taskId':mission.id,
            'pageNo':1,
            'pageSize':50,
            'queryType':mission.queryType
        };

        sessionStorage.setItem('searchData',JSON.stringify(searchData));

        if(mission.queryType==0||mission.queryType==2||mission.queryType==4){
            $state.go('main.sResult.detail',{'type':'tv'});
        }else{
            $state.go('main.sResult.detail',{'type':'variety'});
        }

    };

    $scope.$on('$viewContentLoaded',function() {
        function rotate() {
            $('.mz-load-waiting > img').animate({rotate: '360'}, 2000, 'linear', function () {
                rotate();
            });
        }

        rotate();
    });

    $scope.dumpExcelById = function(missionId){
        dataFetcherService.dumpExcelById(missionId);
    }

    /*$scope.$on('delete_mission_child', function(event, data) {
        if(data.type=='unread'){
            for(var i in $scope.allFinishMission.list){
                if($scope.allFinishMission.list[i].id==data.id){
                    $scope.allFinishMission.list.splice(i,1);
                    $scope.allFinishMission.count -=1;
                    $scope.allFinishMission.currentRecords -=1;
                    break;
                }
            }
        }
    });*/
}]);
